package com.sd.serv1;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

@SuppressWarnings("serial")
public class Login extends HttpServlet{
	public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{
		
		try{
			PrintWriter out=res.getWriter();
			
			ServletConfig sc=getServletConfig();
			
			String driver=sc.getInitParameter("driver");
			String url=sc.getInitParameter("url");
			String uname=sc.getInitParameter("uname");
			String pwd=sc.getInitParameter("pwd");
			String tabl=sc.getInitParameter("tname");
			out.println("in table.....");
			Class.forName(driver);
			out.println("register.....");
			//DriverManager.registerDriver(driver);
			Connection conn=DriverManager.getConnection(url,uname,pwd);
			out.println("connectio.........");
			Statement st=conn.createStatement();
			ResultSet rs=st.executeQuery("select * from "+tabl);
			out.println("in side table.......");
			
			
			while(rs.next()){
				//out.println("<h2>"+rs.getString(1)+"   "+rs.getString(2)+"<h2>");
				out.println("<h2>"+rs.getInt(1)+"<h2/>");
				out.println("<h2>"+rs.getString(2)+"<h2/>");
				
			}
			conn.close();
			st.close();
			out.close();
		}catch(Exception e){
			System.out.println(e);
		}
	}
}
